<template>
  <view>
    <view style="background-color: #f4f5f7">
      <view style="padding: 0.3rem; text-align: center">-商品信息-</view>
    </view>

    <view class="inputS">
      <u-form :model="form" ref="uForm">
        <u-form-item
          placeholder="123"
          style="padding: 0.7rem 1rem"
          prop="name"
          label-width="auto"
          label="商户名称"
          ><u-input v-model="form.name"
          placeholder='请填写商户名称'
        /></u-form-item>
        <u-form-item
          style="padding: 0.7rem 1rem"
          prop="intro"
          label-width="auto"
          label="商户账号"
          ><u-input v-model="form.intro"
             placeholder='请填写商户账号'
        /></u-form-item>

         <u-form-item
          style="padding: 0.7rem 1rem"
          prop="intro"
          label-width="auto"
          label="账号密码"
          ><u-input v-model="form.intro"
             placeholder='请填写商户登录账号密码'
        /></u-form-item>

        <u-form-item
          style="padding: 0.7rem 1rem"
          prop="sex"
          label-width="auto"
          label="联系手机号"
          ><u-input v-model="form.sex"
            placeholder='请填写商户联系手机号'
        /></u-form-item>

      </u-form>
    </view>

    <view class="footP">
      <view
        @click="addPosM"
        style="padding: 0.7rem; display: flex; align-items: center"
      >
        <!-- <img style="width: 1rem;" src="../../style/image/cargo/add.jpg" alt=""> -->
        <view style="color: white; margin-left: 0.2rem">下一步</view>
      </view>
    </view>
  </view>
</template>

<script lang='ts' >
import { Component, Prop, Vue, Watch, Emit } from "vue-property-decorator";

@Component({
  //   @Component  是一个装修器   不可以在下面写语句
  name: "test",
})
export default class extends Vue {
  @Prop({
    type: String, // 父组件传递给子组件的数据类型
    required: false, // 是否必填
    default: " ", // 默认值， 如果传入的是 Object，则要 default: ()=>({}) 参数为函数
  })
  msg!: string;

  public form = {
    name: "",
    intro: "",
    sex: "",
  };
  public rules = {
    name: [
      {
        required: true,
        message: "请输入姓名",
        // 可以单个或者同时写两个触发验证方式
        trigger: ["change", "blur"],
      },
    ],
    intro: [
      {
        // min: 5,
        message: "简介不能少于5个字",
        // trigger: 'change'
      },
    ],
  };

  onReady() {

    // this.$refs.uForm.setRules(this.rules);
    (this.$refs['uForm'] as any).setRules(this.rules)

    console.log(123);
  }
  created() {
    // this.$refs.uForm.setRules(this.rules);
  }

  mounted() {
    //  console.log('父组件传递的参数:',this.$parent)   //暂时不考虑
    //this.$refs.uForm.setRules(this.rules);
  }
}
</script>

<style  scoped>
.footP {
  position: absolute;
  bottom: 0;
  background-color: #02af74;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>